
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<span style="font-size:18px;">
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="weddingPhotography/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="weddingPhotography/css/commonly-used-show.css" />
    <script type="text/javascript" src="weddingPhotography/js/jquery.min.js"></script>
    <script type="text/javascript" src="weddingPhotography/js/bootstrap.js" ></script>

    <link rel="stylesheet" type="text/css" href="weddingPhotography/css/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="weddingPhotography/css/modal.css" />
    <script type="text/javascript" src="weddingPhotography/js/modal.js" ></script>

    <title>最新资讯</title>

    <style>
        .newsdiv{
            border: 1px solid black;
            margin: 30px auto;
            height: 200px;
            padding: 40px;
            border-radius: 5px;
        }
    </style>
</head>

<body class="mybody">

<jsp:include page="theTopMenuAdmin.jsp" />

<div class="container">
     <h3 style="text-align: center">结婚资讯</h3>
     <hr style="filter: alpha(opacity=100,finishopacity=0,style=3)" width="100%" color="#6f5999" size="3"/>
    <div id="personal_user" style="margin-left: 10%; margin-right: 10%">

         <c:forEach items="${adminallnews}" var="news" varStatus="xh">
             <div class="newsdiv">
                <a href="#" style="float: left">
                    <img src="${pageContext.request.contextPath}${news.newsImage}" width="100px" height="100px">
                </a>
                <div style="float: left; margin-left: 50px;">
                    <a href="#" >
                        <span>${news.newsTitle}</span>
                    </a>
                    <p style="margin-top: 20px">
                        <span>${news.createTime}</span>
                    </p>
                </div>

                 <div style="float: right; ">
                     <a class="btn btn-default btn-sm" href="${pageContext.request.contextPath}/adminUpdateLatestNews?id=${news.id}">修改</a>
                      <br>
                      <br>
                     <a class="btn btn-default btn-sm" href="#" onclick="deletNwes('${news.id}')">删除</a>
                 </div>
            </div>

         </c:forEach>


        <div class="form-group text-center same-line-clear">
           <a class="btn btn-primary" href="${pageContext.request.contextPath}/adminLatestNews">添加资讯</a>
        </div>
        </div>

</div>


<script type="text/javascript">
    var userdt = JSON.parse(sessionStorage.getItem("user"));
    if (userdt.result.userName != null){
        $("#usname").text(userdt.result.userName);
    }else {
        $("#usname").text(userdt.result.userLoginName);
    }

    function deletNwes(datees){
        var mModal2 = new mModal({
            top: "40vh",
            content: "你确定要删除此项？",
            confirm: function () {
                deletNwes1(datees);
                mModal2.close();
            },
            cancel: function () {
            }
        });

        mModal2.renderDom();

    }

    function deletNwes1(id){
        var postUrl = "${pageContext.request.contextPath}/member/deletNwes";
        var str = {
            "id": id
        };

        $.ajax({
            type:"post",
            url:postUrl,
            headers: {
                "Content-Type":"application/json"
            },
            data:JSON.stringify(str),
            contentType: "application/json; charset=utf-8",
            dataType:"json",
            success:function(data){
                if (data.status == "0"){
                    alert(data.msg)
                }else {
                    location.reload();
                }
            },
            error:function(xhr,state,errorThrown){
                //alert("发生网络错误，错误码为：" + xhr.status)
                location.href = "${pageContext.request.contextPath}/error";
            }
        });
    }

</script>

</body>
</html>
</span>